package com.dst.smart.dao.impl.factory;

import java.util.ArrayList;
import java.util.List;

import com.dst.smart.app.MyApplication;
import com.dst.smart.model.DeviceType;

public class DeviceTypeFactory {
	public static List<DeviceType> list = new ArrayList<DeviceType>();

	static {
		if (list.size() == 0) {
			list = MyApplication.getInstance().getWidgetDataBase()
					.getDeviceType();
		}
	}

	public static List<DeviceType> getAll() {
		if (list.size() == 0) {
			list = MyApplication.getInstance().getWidgetDataBase()
					.getDeviceType();
		}
		return list;
	}

	public void clearList() {
		list = MyApplication.getInstance().getWidgetDataBase().getDeviceType();
	}

	public static List<DeviceType> getDeviceType(int isShow) {

		List<DeviceType> resultList = new ArrayList<DeviceType>();
		if (list.size() == 0) {
			list = MyApplication.getInstance().getWidgetDataBase()
					.getDeviceType();
		}

		if (list.size() > 0) {
			for (DeviceType deviceType : list) {
				if (deviceType.getIsShow() == isShow) {
					resultList.add(deviceType);
				}
			}
		}
		return resultList;
	}
}
